<?php 
class Blog extends CI_Controller{
	
	
	 public function __construct()
       {
            parent::__construct();
        	$this->output->enable_profiler(PROFILER);
       }	
	
	public function index(){
		
		$this->load->model("postmodel");
		
		$data['name']="Raul Ivan Garcia Valdivia";
		$data['main_content']="public/blog/index";
		
		$data['latest_post']=$this->postmodel->getLastestPost();
		if($data['latest_post']){
		$data['related_comments'] = $this->postmodel->getRelatedPostComments($data['latest_post']->id);
		}
		
		$this->load->view("includes/public/template",$data);
	}
	
	public function add_comment(){
		
	$this->load->model("postmodel");
	$comment_id = $this->postmodel->add_comment($_POST);	
	if($comment_id){
		redirect('blog/index#comment'.$comment_id);
	}else{
		//TBD
	}	
		
		
	}
}

?>